package com.bosicloud.cmb.ibp.microplatform.config;


import com.bosicloud.cmb.ibp.commom.dto.exchange.ExchangeMessage;
import com.bosicloud.cmb.ibp.microplatform.component.MessageExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.aws.messaging.listener.SqsMessageDeletionPolicy;
import org.springframework.cloud.aws.messaging.listener.annotation.SqsListener;
import org.springframework.context.annotation.Configuration;

import static com.bosicloud.cmb.ibp.commom.constant.QueueConstant.IBP_AWS_SQS_RESPONSE_MICROPLATFORM_KEY;

/**
 * @author Jack Peng / ziliang.peng@bosicloud.com
 */
@Slf4j
@Configuration
public class MessageConfig {


    @Autowired
    private MessageExecutor messageExecutor;

    @SqsListener(value = IBP_AWS_SQS_RESPONSE_MICROPLATFORM_KEY, deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
    public void onReciveMessage(ExchangeMessage payload) {
        messageExecutor.receiveLogic(payload);
    }



}
